

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Getting Started &mdash; Cortex2.0  documentation</title>
  

  
  
  
  

  

  
  
    

  

  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="cortex" href="modules.html" />
    <link rel="prev" title="Installation" href="install.html" /> 

  
  <script src="_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="index.html" class="icon icon-home"> Cortex2.0
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">User Documentation</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="install.html">Installation</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Getting Started</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#configuration">Configuration</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#configuration-file-example">Configuration File Example</a></li>
<li class="toctree-l3"><a class="reference internal" href="#usage">Usage</a></li>
<li class="toctree-l3"><a class="reference internal" href="#built-ins">Built-ins</a></li>
<li class="toctree-l3"><a class="reference internal" href="#options">Options</a></li>
<li class="toctree-l3"><a class="reference internal" href="#usage-example">Usage Example</a></li>
<li class="toctree-l3"><a class="reference internal" href="#custom-models">Custom models</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules.html">cortex</a></li>
<li class="toctree-l1"><a class="reference internal" href="develop.html">Develop</a></li>
<li class="toctree-l1"><a class="reference internal" href="build.html">Custom demos</a></li>
<li class="toctree-l1"><a class="reference internal" href="build.html#a-walkthrough-a-custom-classifier">A walkthrough a custom classifier:</a></li>
<li class="toctree-l1"><a class="reference internal" href="build.html#defining-losses-and-results">Defining losses and results</a></li>
<li class="toctree-l1"><a class="reference internal" href="build.html#visualization">Visualization</a></li>
<li class="toctree-l1"><a class="reference internal" href="build.html#putting-it-together">Putting it together</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">Cortex2.0</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
      <li>Getting Started</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/getting_started.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="getting-started">
<h1>Getting Started<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h1>
<div class="section" id="configuration">
<h2>Configuration<a class="headerlink" href="#configuration" title="Permalink to this headline">¶</a></h2>
<p>The first thing to do is to set up the config.yaml. This file is
user-specific (it got tracked at some point, so I need to fix this), and
will tell cortex everything user-specific regarding data locations,
visualation, and outputs.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rm -rf ~/.cortex.yml
$ cortex setup
</pre></div>
</div>
<div class="section" id="configuration-file-example">
<h3>Configuration File Example<a class="headerlink" href="#configuration-file-example" title="Permalink to this headline">¶</a></h3>
<p>Located at <code class="docutils literal notranslate"><span class="pre">~/.cortex.yml</span></code></p>
<div class="code python highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">torchvision_data_path</span><span class="p">:</span> <span class="o">/</span><span class="n">data</span><span class="o">/</span><span class="n">milatmp1</span><span class="o">/</span><span class="n">hjelmdev</span><span class="o">/</span><span class="n">data</span><span class="o">/</span>
<span class="n">data_paths</span><span class="p">:</span> <span class="p">{</span>
 <span class="n">Imagenet</span><span class="o">-</span><span class="mi">12</span><span class="p">:</span> <span class="o">/</span><span class="n">data</span><span class="o">/</span><span class="n">lisa</span><span class="o">/</span><span class="n">data</span><span class="o">/</span><span class="n">ImageNet2012_jpeg</span><span class="p">,</span> <span class="n">CelebA</span><span class="p">:</span> <span class="o">/</span><span class="n">tmp</span><span class="o">/</span><span class="n">hjelmdev</span><span class="o">/</span><span class="n">CelebA</span><span class="p">}</span><span class="n">viz</span><span class="p">:</span> <span class="p">{</span>
 <span class="n">font</span><span class="p">:</span> <span class="o">/</span><span class="n">usr</span><span class="o">/</span><span class="n">share</span><span class="o">/</span><span class="n">fonts</span><span class="o">/</span><span class="n">truetype</span><span class="o">/</span><span class="n">liberation</span><span class="o">/</span><span class="n">LiberationSerif</span><span class="o">-</span><span class="n">Regular</span><span class="o">.</span><span class="n">ttf</span><span class="p">,</span> <span class="n">server</span><span class="p">:</span> <span class="s1">&#39;http://132.204.26.180&#39;</span><span class="p">}</span>
<span class="n">out_path</span><span class="p">:</span> <span class="o">/</span><span class="n">data</span><span class="o">/</span><span class="n">milatmp1</span><span class="o">/</span><span class="n">hjelmdev</span><span class="o">/</span><span class="n">outs</span><span class="o">/</span>
</pre></div>
</div>
<p>These are as follows:</p>
<ul>
<li><p class="first">torchvision_data_path: the path to all torchvision-specific
datasets (details can be found in torchvision.datasets)</p>
</li>
<li><p class="first">data_paths: user-specified custom datasets. Currently, only support
is for image folders (a la imagenet), but other dataset types (e.g.,
text) are planned in the near-future.</p>
</li>
<li><p class="first">vis: visdom specific arguments.</p>
</li>
<li><div class="first line-block">
<div class="line">out_path: Out path for experiment outputs</div>
</div>
</li>
</ul>
</div>
<div class="section" id="usage">
<h3>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h3>
<blockquote>
<div>cortex –help</div></blockquote>
</div>
<div class="section" id="built-ins">
<h3>Built-ins<a class="headerlink" href="#built-ins" title="Permalink to this headline">¶</a></h3>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">setup:</th><td class="field-body">Setup cortex configuration.</td>
</tr>
<tr class="field-even field"><th class="field-name">GAN:</th><td class="field-body">Generative adversarial network.</td>
</tr>
<tr class="field-odd field"><th class="field-name">VAE:</th><td class="field-body">Variational autoencoder.</td>
</tr>
<tr class="field-even field"><th class="field-name" colspan="2">AdversarialAutoencoder:</th></tr>
<tr class="field-even field"><td>&#160;</td><td class="field-body">Adversarial Autoencoder.</td>
</tr>
<tr class="field-odd field"><th class="field-name">ALI:</th><td class="field-body">Adversarially learned inference.</td>
</tr>
<tr class="field-even field"><th class="field-name" colspan="2">ImageClassification:</th></tr>
<tr class="field-even field"><td>&#160;</td><td class="field-body">Basic image classifier.</td>
</tr>
<tr class="field-odd field"><th class="field-name">GAN_MINE:</th><td class="field-body">GAN + MINE.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="options">
<h3>Options<a class="headerlink" href="#options" title="Permalink to this headline">¶</a></h3>
<table class="docutils option-list" frame="void" rules="none">
<col class="option" />
<col class="description" />
<tbody valign="top">
<tr><td class="option-group">
<kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></td>
<td>show this help message and exit</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-o <var>OUT_PATH</var></span>, <span class="option">--out_path <var>OUT_PATH</var></span></kbd></td>
</tr>
<tr><td>&#160;</td><td>Output path directory. All model results will go
here. If a new directory, a new one will be
created, as long as parent exists.</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-n <var>NAME</var></span>, <span class="option">--name <var>NAME</var></span></kbd></td>
</tr>
<tr><td>&#160;</td><td>Name of the experiment. If given, base name of
output directory will be <cite>–name</cite>. If not given,
name will be the base name of the <cite>–out_path</cite></td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-r <var>RELOAD</var></span>, <span class="option">--reload <var>RELOAD</var></span></kbd></td>
</tr>
<tr><td>&#160;</td><td>Path to model to reload.</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-M <var>LOAD_MODELS</var></span>, <span class="option">--load_models <var>LOAD_MODELS</var></span></kbd></td>
</tr>
<tr><td>&#160;</td><td>Path to model to reload. Does not load args, info,
etc</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-m <var>META</var></span>, <span class="option">--meta <var>META</var></span></kbd></td>
</tr>
<tr><td>&#160;</td><td>TODO</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-c <var>CONFIG_FILE</var></span>, <span class="option">--config_file <var>CONFIG_FILE</var></span></kbd></td>
</tr>
<tr><td>&#160;</td><td>Configuration yaml file. See <cite>exps/</cite> for examples</td></tr>
<tr><td class="option-group">
<kbd><span class="option">-k</span>, <span class="option">--clean</span></kbd></td>
<td>Cleans the output directory. This cannot be undone!</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-v <var>VERBOSITY</var></span>, <span class="option">--verbosity <var>VERBOSITY</var></span></kbd></td>
</tr>
<tr><td>&#160;</td><td>Verbosity of the logging. (0, 1, 2)</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">-d <var>DEVICE</var></span>, <span class="option">--device <var>DEVICE</var></span></kbd></td>
</tr>
<tr><td>&#160;</td><td>TODO</td></tr>
</tbody>
</table>
</div>
<div class="section" id="usage-example">
<h3>Usage Example<a class="headerlink" href="#usage-example" title="Permalink to this headline">¶</a></h3>
<p>To run an experiment.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cortex</span> <span class="n">GAN</span> <span class="o">--</span><span class="n">d</span><span class="o">.</span><span class="n">source</span> <span class="n">CIFAR10</span> <span class="o">--</span><span class="n">d</span><span class="o">.</span><span class="n">copy_to_local</span>
</pre></div>
</div>
</div>
<div class="section" id="custom-models">
<h3>Custom models<a class="headerlink" href="#custom-models" title="Permalink to this headline">¶</a></h3>
<p>It is possible to run experiments with custom models made with Pytorch under the Cortex framework. For doing so, the model has to
be added to the demos folder under the root of the project. You can have a look to the given demo autoencoder and classifier already
implemented. The main difference is that, rather than registering the plugins, the run function of main.py has to be called. For example,</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
<span class="n">classifier</span> <span class="o">=</span> <span class="n">MyClassifier</span><span class="p">()</span>
<span class="n">run</span><span class="p">(</span><span class="n">model</span><span class="o">=</span><span class="n">classifier</span><span class="p">)</span>
</pre></div>
</div>
<p>To run an experiment with a custom model.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">my_model</span><span class="o">.</span><span class="n">py</span> <span class="o">--</span><span class="n">d</span><span class="o">.</span><span class="n">source</span> <span class="o">&lt;</span><span class="n">Dataset</span><span class="o">&gt;</span> <span class="o">--</span><span class="n">d</span><span class="o">.</span><span class="n">copy_to_local</span>
</pre></div>
</div>
</div>
</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="modules.html" class="btn btn-neutral float-right" title="cortex" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="install.html" class="btn btn-neutral" title="Installation" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2018, MILA.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'./',
            VERSION:'',
            LANGUAGE:'None',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true,
            SOURCELINK_SUFFIX: '.txt'
        };
    </script>
      <script type="text/javascript" src="_static/jquery.js"></script>
      <script type="text/javascript" src="_static/underscore.js"></script>
      <script type="text/javascript" src="_static/doctools.js"></script>
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

  

  <script type="text/javascript" src="_static/js/theme.js"></script>

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>